<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>async (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
       <span class="fn">async</span>
</div>

<hr/>


  <h2>Classes</h2>
 <div class="fn-constructor">
        <a href="class_goog_async_AnimationDelay.html">
          goog.async.AnimationDelay</a><br/>
        <div class="class-details">A delayed callback that pegs to the next animation frame
instead of a user configurable timeout. By design, this should have
the same interface as goog.async.Delay.

Uses requestAnimationFrame and friends when available, but falls
back to a timeout of goog.async.AnimationDelay.TIMEOUT.

For more on requestAnimationFrame and how you can use it to create smoother
animations, see:
</div>
 </div>
 <div class="fn-constructor">
        <a href="class_goog_async_ConditionalDelay.html">
          goog.async.ConditionalDelay</a><br/>
        <div class="class-details">A ConditionalDelay object invokes the associated function after a specified
interval delay and checks its return value. If the function returns
<code> true</code> the conditional delay is cancelled and 
is called. Otherwise this object keeps to invoke the deferred function until
either it returns <code> true</code> or the timeout is exceeded. In the latter case
the  method will be called.

The interval duration and timeout can be specified each time the delay is
started. Calling start on an active delay will reset the timer.

</div>
 </div>
 <div class="fn-constructor">
        <a href="class_goog_async_Deferred.html">
          goog.async.Deferred</a><br/>
        <div class="class-details">A Deferred represents the result of an asynchronous operation. A Deferred
instance has no result when it is created, and is "fired" (given an initial
result) by calling <code> callback</code> or <code> errback</code>.

Once fired, the result is passed through a sequence of callback functions
registered with <code> addCallback</code> or <code> addErrback</code>. The functions may
mutate the result before it is passed to the next function in the sequence.

Callbacks and errbacks may be added at any time, including after the Deferred
has been "fired". If there are no pending actions in the execution sequence
of a fired Deferred, any new callback functions will be called with the last
computed result. Adding a callback function is the only way to access the
result of the Deferred.

If a Deferred operation is canceled, an optional user-provided cancellation
function is invoked which may perform any special cleanup, followed by firing
the Deferred's errback sequence with a <code> CanceledError</code>. If the
Deferred has already fired, cancellation is ignored.

Deferreds may be templated to a specific type they produce using generics
with syntax such as:
<code>
  /** @type {goog.async.Deferred.} */
  var d = new goog.async.Deferred();
  // Compiler can infer that foo is a string.
  d.addCallback(function(foo) {...});
  d.callback('string');  // Checked to be passed a string
</code>
Since deferreds are often used to produce different values across a chain,
the type information is not propagated across chains, but rather only
associated with specifically cast objects.

</div>
 </div>
 <div class="fn-constructor">
        <a href="class_goog_async_DeferredList.html">
          goog.async.DeferredList</a><br/>
        <div class="class-details">Constructs an object that waits on the results of multiple asynchronous
operations and marshals the results. It is itself a <code>Deferred</code>,
and may have an execution sequence of callback functions added to it. Each
<code>DeferredList</code> instance is single use and may be fired only once.

The default behavior of a <code>DeferredList</code> is to wait for a success
or error result from every <code>Deferred</code> in its input list. Once
every result is available, the <code>DeferredList</code>'s execution sequence
is fired with a list of <code>[success, result]</code> array pairs, where
<code>success</code> is a boolean indicating whether <code>result</code> was
the product of a callback or errback. The list's completion criteria and
result list may be modified by setting one or more of the boolean options
documented below.

<code>Deferred</code> instances passed into a <code>DeferredList</code> are
independent, and may have additional callbacks and errbacks added to their
execution sequences after they are passed as inputs to the list.

</div>
 </div>
 <div class="fn-constructor">
        <a href="class_goog_async_Delay.html">
          goog.async.Delay</a><br/>
        <div class="class-details">A Delay object invokes the associated function after a specified delay. The
interval duration can be specified once in the constructor, or can be defined
each time the delay is started. Calling start on an active delay will reset
the timer.

</div>
 </div>
 <div class="fn-constructor">
        <a href="class_goog_async_Throttle.html">
          goog.async.Throttle</a><br/>
        <div class="class-details">Throttle will perform an action that is passed in no more than once
per interval (specified in milliseconds). If it gets multiple signals
to perform the action while it is waiting, it will only perform the action
once at the end of the interval.
</div>
 </div>
   
<br/>

  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>




  <h2>Global Functions</h2>





<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.async.nextTick"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.async.</span><span class="entryName">nextTick<span class="args">(<span class="arg">callback</span>,&nbsp;<span class="arg">opt_context</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Fires the provided callbacks as soon as possible after the current JS
execution context. setTimeout(?, 0) always takes at least 5ms for legacy
reasons.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">callback</span>
        : <span class="type">function(this:SCOPE</span>)
        <div class="entryOverview">Callback function to fire as soon as
    possible.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_context</span>
        : <span class="type">SCOPE=</span>
        <div class="entryOverview">Object in whose scope to call the listener.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_async_nexttick.js.source.html#line37">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.async.run"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.async.</span><span class="entryName">run<span class="args">(<span class="arg">callback</span>,&nbsp;<span class="arg">opt_context</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Fires the provided callback just before the current callstack unwinds, or as
soon as possible after the current JS execution context.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">callback</span>
        : <span class="type">function(this:THIS</span>)
        <div class="entryOverview"><span class='nodesc'>No description.</span></div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_context</span>
        : <span class="type">THIS=</span>
        <div class="entryOverview">Object to use as the "this value" when calling
    the provided function.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_async_run.js.source.html#line43">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.async.throwException"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.async.</span><span class="entryName">throwException<span class="args">(<span class="arg">exception</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Throw an item without interrupting the current execution context.  For
example, if processing a group of items in a loop, sometimes it is useful
to report an error while still allowing the rest of the batch to be
processed.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">exception</span>
        : <span class="type">*</span>
        <div class="entryOverview"><span class='nodesc'>No description.</span></div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_async_run.js.source.html#line29">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>



  <h2>Global Properties</h2>





<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.async.AnimationDelayTest"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.async.</span><span class="entryName">AnimationDelayTest</span>
        : 
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_async_animationdelay_test.js.source.html#line14">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>





  <a name="goog.async.ConditionalDelayTest"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.async.</span><span class="entryName">ConditionalDelayTest</span>
        : 
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_async_conditionaldelay_test.js.source.html#line14">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.async.DelayTest"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.async.</span><span class="entryName">DelayTest</span>
        : 
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_async_delay_test.js.source.html#line14">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>





  <a name="goog.async.ThrottleTest"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.async.</span><span class="entryName">ThrottleTest</span>
        : 
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_async_throttle_test.js.source.html#line14">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.async.nextTickTest"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.async.</span><span class="entryName">nextTickTest</span>
        : 
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_async_nexttick_test.js.source.html#line14">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>





  <a name="goog.async.runTest"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.async.</span><span class="entryName">runTest</span>
        : 
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_async_run_test.js.source.html#line15">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Package async</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">Package Reference</h2>
            <div id="sideTypeIndex" rootPath="" current="async"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
